import java.util.Random;
import java.util.Scanner;

public class LogicalControl {
    //Java的循环输入语句测试计算平均值
    public static void main(String[] args) {
        int num = 0;
        int sum = 0;
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()){
            int temp = sc.nextInt();
            sum += temp;
            num++;
        }
        System.out.println("sum = " + sum);
        System.out.println("avg = " + sum / num);
        sc.close();
    }
    //Java的单个输入语句测试
    public static void main5(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //接收一个整型单位
        int num1 = scanner.nextInt();
        //接收一行的字符
        String s1 = scanner.nextLine();
        //类似C文件操作，用完记得关闭
        scanner.close();
    }
    //Java的输出语句测试
    public static void main4(String[] args) {
        String msg = "abcde";
        int set = 10;
        ////int型和字符串中间加个+号，IDEA就会将int型变量也转换成字符串并连接
        System.out.println(set + "abc");
        System.out.println(msg); // 输出一个字符串, 带换行
        System.out.print(msg); // 输出一个字符串, 不带换行
        System.out.printf("\n%d", set); // 先换行再格式化输出
    }
    //猜数字游戏
    public static void main3(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        int n = random.nextInt(100);
        boolean flag = false;
        do{
            System.out.print("请猜数：");
            int input = scanner.nextInt();
            if(input > n){
                System.out.println("猜大了！");
            } else if (input < n) {
                System.out.println("猜小了！");
            }else {
                System.out.println("恭喜你，猜对了！");
                flag = true;
            }
        }while(flag == false);
    }
    public static void main2(String[] args) {
        int i = 1;
        while ((i <= 100)){
            if((i % 3 == 0) && (i % 5 == 0)){
                System.out.print(i+" ");
                i += 5;
                continue;
            }
            i++;
        }
    }
    public static void main1(String[] args) {
        int i = 1;
        int j = 1;
        int ret = 1;
        int sum = 0;
        while (i <= 5) {
            j = i;
            ret = 1;
            while(j>=1){
                ret *= j;
                j--;
            }
            sum += ret;
            i++;
        }
        System.out.println(sum);
    }
}
